import {
  mergeProps,
  type ParentComponent,
} from "solid-js";
import type { FcFormSubmitProps } from "./types";
import BsButton from "@lib/Button";
import { useFormContext } from "solid-form-context";

const defaultProps: Partial<FcFormSubmitProps> = {
  variant: "primary",
  children: "提交",
};

const FcFormSubmit: ParentComponent<FcFormSubmitProps> = (p) => {
  const props = mergeProps(defaultProps, p);
  const form = useFormContext();

  return <BsButton {...props} onClick={() => form?.submit?.()}></BsButton>;
};

export default FcFormSubmit

export * from './types'
